package com.lin.community.controller;

import com.lin.community.dto.PageDTO;
import com.lin.community.service.QuestionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * @ClassName IndexController
 * @Description: TODO
 * @Author 林
 * @Date 2020/1/27 0027
 * @Version V1.0
 **/
@Controller
public class IndexController {

    @Autowired
    private QuestionService questionService;

    @GetMapping("/")
    public String index(Model model,
                        @RequestParam(name = "page",defaultValue = "1")Integer page,
                        @RequestParam(name = "size",defaultValue = "2")Integer size) {

        PageDTO pageDTO = questionService.list(page,size);
        model.addAttribute("pages",pageDTO);
        return "index";
    }
}
